Portfolio Learn Month 01 Kali Basics

🔄 Day 7: Process States

Linux
Kali

State is just a snapshot of a process at a moment. 📸


🧊 The 4 Main Process States

State Name Description
R Running The process is running or ready to run.
S Sleeping Waiting for an event or I/O. (Very common).
T Stopped Suspended by a signal like SIGSTOP or SIGSTP (Ctrl+Z).
Z Zombie 🧟 Finished execution but still in the process table.

Zombie Example: A person has passed away, but their official records still show them as "Alive" because the death certificate hasn't been processed. The record exists, but the entity is gone. ☠️


🔗 States & Signals

Signals change the state of a process. Here is the relationship:

SIGNAL Effect / New State
SIGINT Gone (Stopped & Cleared)
SIGTERM Gone (Polite Stop)
SIGSTP T (Stopped/Paused)
SIGSTOP T (Stopped/Paused)
SIGCONT R or S (Running/Sleeping)
SIGKILL Gone (Forced Kill)

Note:


🎮 Practice Scenarios

  1. Open Terminal: Open your terminal in Kali.
  2. Split Terminal: Use Ctrl + Shift + R (or your shortcut).
  3. Start Process:
    In the left terminal:
    sleep 500
  4. Check State:
    In the right terminal:
    ps aux | grep "sleep 500"
    You should see S+ (Sleeping + Foreground).
  5. Background It:
    Pause (Ctrl + Z) and send to background (bg).
  6. Check State Again:
    Run the ps command again.
    You will now see S (Sleeping, no +).
  7. Stop It:
    Send a SIGSTOP to the PID.
  8. Final Check:
    Check status again. You should see T (Stopped).